﻿namespace com.stifel.BranchMgmt.WebParts.BranchView
{
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;

    using com.stifel.Extensions.StringExtensions;

    public partial class BranchViewUserControl : UserControl
    {
        #region Fields

        bool uiBasics_Loaded;
        bool uiHardware_Loaded;
        bool uiLease_Loaded;
        bool uiNetwork_Loaded;
        bool uiPersonnel_Loaded;
        bool uiPhone_Loaded;
        bool uiPhotos_Loaded;
        bool uiUpdates_Loaded;

        #endregion Fields

        #region Methods

        protected void Page_Load( object sender, EventArgs e )
        {
            setDefaultView( );
        }

        protected void uiBasics_Activate( object sender, EventArgs e )
        {
            if ( !uiBasics_Loaded )
            {
                loadBasics( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) );
                uiBasics_Loaded = true;
            }
        }

        protected void uiBasics_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiHardware_Activate( object sender, EventArgs e )
        {
            if ( !uiHardware_Loaded )
            {
                loadHardware( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiHardware_Loaded = true;
            }
        }

        protected void uiHardware_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiHardware_ItemDataBound( object sender, RepeaterItemEventArgs e )
        {
        }

        protected void uiLease_Activate( object sender, EventArgs e )
        {
            if ( !uiLease_Loaded )
            {
                loadLease( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiLease_Loaded = true;
            }
        }

        protected void uiLease_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiNavigationTab_Click( object sender, EventArgs e )
        {
            Button button = sender as Button;
            navigateToSelectedView( button );
        }

        protected void uiNetwork_Activate( object sender, EventArgs e )
        {
            if ( !uiNetwork_Loaded )
            {
                loadNetwork( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiNetwork_Loaded = true;
            }
        }

        protected void uiNetwork_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiNetwork_ItemDataBound( object sender, RepeaterItemEventArgs e )
        {
        }

        protected void uiPersonnel_Activate( object sender, EventArgs e )
        {
            if ( !uiPersonnel_Loaded )
            {
                loadPersonnel( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiPersonnel_Loaded = true;
            }
        }

        protected void uiPersonnel_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiPersonnel_ItemDataBound( object sender, RepeaterItemEventArgs e )
        {
        }

        protected void uiPhone_Activate( object sender, EventArgs e )
        {
            if ( !uiPhone_Loaded )
            {
                loadPhone( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiPhone_Loaded = true;
            }
        }

        protected void uiPhone_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiPhone_ItemDataBound( object sender, RepeaterItemEventArgs e )
        {
        }

        protected void uiPhotos_Activate( object sender, EventArgs e )
        {
            if ( !uiPhotos_Loaded )
            {
                loadPhotos( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiPhotos_Loaded = true;
            }
        }

        protected void uiPhotos_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiUpdates_Activate( object sender, EventArgs e )
        {
            if ( !uiUpdates_Loaded )
            {
                loadUpdates( getBranchId( HttpContext.Current.Request.QueryString[ "ItemGuid" ].ToGuid( ) ) );
                uiUpdates_Loaded = true;
            }
        }

        protected void uiUpdates_Deactivate( object sender, EventArgs e )
        {
        }

        protected void uiView_OnLoad( object sender, EventArgs e )
        {
            navigateToSelectedView( uiBtnBasics );
        }

        #endregion Methods
    }
}